/*这是获得套接字IO缓冲区大小的程序*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>

int main(int argc, char **argv)
{
    int sock;
    int snd_buf, rcv_buf, state;
    socklen_t len;

    sock = socket(AF_INET, SOCK_STREAM, 0);
    len = sizeof(snd_buf);
    state = getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (void *)&snd_buf, &len);
    len = sizeof(rcv_buf);
    state = getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (void *)&rcv_buf, &len);
    printf("输入缓冲区的大小是：%d\n", rcv_buf);
    printf("输出缓冲区的大小是：%d\n", snd_buf);
    return 0;
}